#ifndef GRAPHICPAINTER_H
#define GRAPHICPAINTER_H

#include "common/vector.h"
#include "common/utils.h"

namespace gui
{
    /**
    *   Graphic Painter Interface
    */

	class GraphicPainter
	{
	    public:
	        virtual ~GraphicPainter();

			virtual void moveTo(int x, int y) = 0;
			virtual void lineTo(int x, int y) = 0;

			virtual void drawGridPoint(const Vector& p) = 0;
			virtual void drawPoint(const Vector& p) = 0;
            virtual void drawLine(const Vector& p1, const Vector& p2) = 0;
            virtual void drawRect(const Vector& p1, const Vector& p2);
            virtual void drawArc(const Vector& cp, double radius,
                         double a1, double a2,
                         const Vector& p1, const Vector& p2,
                         bool reversed) = 0;
            virtual void drawArc(const Vector& cp, double radius,
                         double a1, double a2,
                         bool reversed) = 0;
/*
            void createArc(QPointArray& pa,
                   const Vector& cp, double radius,
                   double a1, double a2,
                   bool reversed);
*/
            virtual void drawCircle(const Vector& cp, double radius) = 0;
            virtual void drawEllipse(const Vector& cp,
                             double radius1, double radius2,
                             double angle,
                             double angle1, double angle2,
                             bool reversed) = 0;
/*
            virtual void drawImg(RS_Img& img, const Vector& pos,
                        double angle, const Vector& factor,
                        int sx, int sy, int sw, int sh) = 0;
*/

            virtual void drawTextH(int x1, int y1, int x2, int y2,
                           const std::string& text) = 0;
            virtual void drawTextV(int x1, int y1, int x2, int y2,
                           const std::string& text) = 0;
/*
            virtual void fillRect(int x1, int y1, int w, int h,
                          const RS_Color& col) = 0;
*/
            virtual void fillTriangle(const Vector& p1,
                              const Vector& p2,
                              const Vector& p3) = 0;

/*
            virtual void drawHandle(const Vector& p, const RS_Color& c, int size=-1);
*/
            virtual void setPreviewPen() = 0;
/*
            virtual RS_Pen getPen() = 0;
            virtual void setPen(const RS_Pen& pen) = 0;
            virtual void setPen(const RS_Color& color) = 0;
*/
            virtual void setPen(int r, int g, int b) = 0;
            virtual void disablePen() = 0;
/*
            virtual void setBrush(const RS_Color& color) = 0;
            virtual void drawPolygon(const RS_PointArray& a) = 0;
*/
            virtual void erase() = 0;
            virtual int getWidth() = 0;
            virtual int getHeight() = 0;

            virtual void setXORMode() = 0;
            virtual void setNormalMode() = 0;


            virtual void setClipRect(int x, int y, int w, int h) = 0;
            virtual void resetClipping() = 0;

            virtual void setOffset(const Vector& o)
            {
                offset = o;
            }

            int toScreenX(double x)
            {
                return Math::round(offset.x + x);
            }
            int toScreenY(double y)
            {
                return Math::round(offset.y + y);
            }


	    protected:
            GraphicPainter();

            /**
            * A fixed offset added to all entities drawn (useful for previews).
            */
            Vector offset;

        private:
	};

}

#endif // GRAPHICPAINTER_H
